
#import <mshtml.tlb>
#import <shdocvw.dll>
void GetIESrc()
{
	SHDocVw::IShellWindowsPtr m_spSHWinds;
	CoInitialize(NULL);
	if(m_spSHWinds.CreateInstance(__uuidof(SHDocVw::ShellWindows)) == S_OK)
	{
		IDispatchPtr spDisp;
		long nCount = m_spSHWinds->GetCount();
		for (long i = 0; i < nCount; i++)
		{
			_variant_t va(i, VT_I4);
			spDisp = m_spSHWinds->Item(va);
			SHDocVw::IWebBrowser2Ptr spBrowser(spDisp);
			if (spBrowser != NULL)
			{
				IDispatchPtr spDisp;
				if(spBrowser->get_Document(&spDisp) == S_OK && spDisp!= 0 )
				{
					MSHTML::IHTMLDocument2Ptr spHtmlDocument(spDisp);
					MSHTML::IHTMLElementPtr spHtmlElement;
					if(spHtmlDocument==NULL)
						continue;
					spHtmlDocument->get_body(&spHtmlElement);
					if(spHtmlDocument==NULL)
						continue;
					_bstr_t str ;
					str=spBrowser->GetLocationURL();//URL of IE window();
					AfxMessageBox(str);
					MSHTML::IHTMLDocument3* pHTMLDoc3;
					HRESULT hr = spHtmlDocument->QueryInterface(__uuidof(MSHTML::IHTMLDocument3),(LPVOID*)&pHTMLDoc3);
					ASSERT(SUCCEEDED(hr));
					MSHTML::IHTMLElement* pDocElem;
					hr = pHTMLDoc3->get_documentElement(&pDocElem);
					pHTMLDoc3->Release();
					ASSERT(SUCCEEDED(hr));
					BSTR bstrHTML;
					pDocElem->get_outerHTML(&bstrHTML);
					pDocElem->Release();
					AfxMessageBox(CString(bstrHTML));
					SysFreeString(bstrHTML);
				}
				break;
			}
		}

	}
	else {
		::AfxMessageBox(L"Shell Windows interface is not avilable");
	}
	CoUninitialize();
}